package cn.com.yusys.yusp.admin.web.rest;

import cn.com.yusys.yusp.admin.domain.AdminSmCrelStra;
import cn.com.yusys.yusp.admin.domain.AdminSmCrelStraList;
import cn.com.yusys.yusp.admin.service.AdminSmCrelStraService;
import cn.com.yusys.yusp.commons.service.CommonService;
import cn.com.yusys.yusp.commons.web.rest.CommonResource;
import cn.com.yusys.yusp.commons.web.rest.dto.ResultDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @项目名称: yusp-admin
 * @类名称: AdminSmCrelStraResource
 * @类描述: 认证策略管理
 * @功能描述: 
 * @创建人: dusong@yusys.com.cn
 * @创建时间: 2017-12-19 13:40
 * @修改备注: 
 * @修改记录: 修改时间    修改人员    修改原因
 * -------------------------------------------------------------
 * @version 1.0.0
 * @Copyright (c) 2017宇信科技-版权所有
 */
@RestController
@RequestMapping("/api/adminsmcrelstra")
public class AdminSmCrelStraResource extends CommonResource<AdminSmCrelStra, String> {
    
    private final Logger logger = LoggerFactory.getLogger(AdminSmCrelStraResource.class);
    
    @Autowired
    private AdminSmCrelStraService adminSmAuthRecoService;

    @Override
    protected CommonService getCommonService() {
        return this.adminSmAuthRecoService;
    }

    /**
    * @方法名称: batchUpdate
    * @方法描述: 批量修改认证策略
    * @参数与返回说明: 
    * @算法描述: 
    */
    @PostMapping("/batchupdate")
    public ResultDto<Integer> batchUpdate(@RequestBody AdminSmCrelStraList crelList){
        int result = this.adminSmAuthRecoService.batchUpdate(crelList.getCrelList());
        ResultDto<Integer> resultDto = new ResultDto<>();
        resultDto.setData(result);
        if(result > 0) {
            resultDto.setMessage("修改认证策略成功");
        }else{
            resultDto.setMessage("修改认证策略失败");
        }
        logger.debug("Modified record number {}", result);
        return resultDto;
    }
}
